﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Aliphant.Mvvm.XEvent.Events;

namespace Aliphant.UI.Forms.Helpers
{
    public class DialogHelper
    {
        /// <summary>
        /// 选择文件夹对话框
        /// </summary>
        /// <param name="windowEvent"></param>
        public static void SelectFolderWindow(WindowEvent windowEvent)
        {
            var fileDialog = new FolderBrowserDialog();
            fileDialog.UseDescriptionForTitle = true;
            fileDialog.ShowNewFolderButton = true;
            var result = fileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                if (windowEvent.CallBack is Action<string> action)
                {
                    action(fileDialog.SelectedPath);
                }
            }
        }
    }
}
